package org.streets.eis.ext.analysis.components;

import java.io.Serializable;
import org.streets.eis.component.model.ListItem;

public class CheckItem implements Serializable {

		private static final long serialVersionUID = 1L;

		private String id;
		private String text;
		private Boolean checked;
		private String icon;

		public static final CheckItem NULL = new CheckItem("","");
		
		public CheckItem(String id,String text){
			this(id,text,null);
		}
		
		public CheckItem(String id,String text,String imgUrl){
			this.id = id;
			this.text = text;
			this.checked = false;
			this.setIcon(imgUrl);
		}
		
		public void setId(String id) {
			this.id = id;
		}

		public String getId() {
			return id;
		}
		
		public void setText(String text) {
			this.text = text;
		}

		public String getText() {
			return text;
		}

		public void setIcon(String icon) {
			this.icon = icon;
		}

		public String getIcon() {
			return icon;
		}
		
		public boolean isNull(){
			return id==null|| id.trim().length() == 0;
		}
		
		@Override
		public int hashCode(){
			return this.id!=null?this.id.hashCode():0;
		}

		@Override
		public boolean equals(Object obj){
			return obj!=null && CheckItem.class.isAssignableFrom(obj.getClass()) &&
				(
						(this.id == null && ((ListItem)obj).getId()==null) ||
						(this.id != null && this.id.equals(((ListItem)obj).getId()))
				);
		}
		
		@Override
		public String toString(){
			return text;
		}

		public void setChecked(Boolean checked) {
			this.checked = checked;
		}

		public Boolean getChecked() {
			return checked;
		}
	}
